//
//  TTIPersonVC.m
//  ContentApp
//
//  Created by apple on 16/8/1.
//  Copyright © 2016年 翔傲科技. All rights reserved.
//

#import "TTIPersonVC.h"
#import "APPHeader.h"
#import "LDActionSheet.h"
#import "LDImagePicker.h"
#import "TTIEditUserInfoVC.h"

@interface TTIPersonVC ()<LDImagePickerDelegate,LDActionSheetDelegate>
@property (weak, nonatomic) IBOutlet UIButton *AvatarBtn;//用户头像
@property (weak, nonatomic) IBOutlet UILabel *UserName;//用户昵称
@property (weak, nonatomic) IBOutlet UILabel *IDNumer;//用户ID
@property (weak, nonatomic) IBOutlet UILabel *PhoneNumer;//用户手机号

@property (nonatomic, strong) LDActionSheet *SelectImgSheet;

- (IBAction)ChangeAvatar:(UIButton *)sender;
- (IBAction)EditUserInfo:(UIButton *)sender;
- (IBAction)MyCollection:(UIButton *)sender;
- (IBAction)MyInterest:(UIButton *)sender;
- (IBAction)MyDownload:(UIButton *)sender;
- (IBAction)GiveFeedback:(UIButton *)sender;
- (IBAction)LoginOut:(UIButton *)sender;

@end

@implementation TTIPersonVC

#pragma mark ---------------------------- 初始化事件 --------------------------
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [self.navigationController setNavigationBarHidden:YES];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];
    [self.navigationController setNavigationBarHidden:NO];
//    [self.navigationController.navigationBar setBackgroundImage:[self createImageWithColor: [UIColor colorWithRed:27/255.0 green:60/255.0 blue:123/255.0 alpha:1/1.0]] forBarMetrics:UIBarMetricsDefault];
//    self.navigationController.navigationBar.translucent = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark ---------------------------- 声明响应事件 --------------------------
#pragma mark --- 点击头像事件
- (IBAction)ChangeAvatar:(UIButton *)sender {
    self.SelectImgSheet = [[LDActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照",@"从相册选择", nil];
    [self.SelectImgSheet showInView:kWindow];
}
#pragma mark --- 点击编辑事件
- (IBAction)EditUserInfo:(UIButton *)sender {
    
    TTIEditUserInfoVC *EditUserInfoVC = ViewControllerWithNameAndIdentifier(@"TTIPerson", @"TTIEditUserInfoVC");
    [self.navigationController pushViewController:EditUserInfoVC animated:YES];
}
#pragma mark --- 点击我的收藏事件
- (IBAction)MyCollection:(UIButton *)sender {
}
#pragma mark --- 点击我的兴趣事件
- (IBAction)MyInterest:(UIButton *)sender {
}
#pragma mark --- 点击我的下载事件
- (IBAction)MyDownload:(UIButton *)sender {
}
#pragma mark --- 点击意见反馈事件
- (IBAction)GiveFeedback:(UIButton *)sender {
}
#pragma mark --- 点击登出事件
- (IBAction)LoginOut:(UIButton *)sender {
}

#pragma mark ---------------------------- 响应事件 --------------------------
#pragma mark --- 更新头像
- (void)uploadIcon
{
    
}

#pragma mark ---------------------------- 代理事件 --------------------------

#pragma mark UIActionSheetDelegate
- (void)actionSheet:(LDActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 0)//拍照
    {
        LDImagePicker *imagePicker = [LDImagePicker sharedInstance];
        imagePicker.delegate = self;
        [imagePicker showImagePickerWithType:buttonIndex InViewController:self Scale:1.0];
    }
    else if (buttonIndex == 1)//相册
    {
        LDImagePicker *imagePicker = [LDImagePicker sharedInstance];
        imagePicker.delegate = self;
        [imagePicker showImagePickerWithType:buttonIndex InViewController:self Scale:1.0];
    }
}

- (void)imagePickerDidCancel:(LDImagePicker *)imagePicker
{
    
}

- (void)imagePicker:(LDImagePicker *)imagePicker didFinished:(UIImage *)editedImage{
    
    //拿到图片
    UIImage *imagesave = editedImage;
    
    // 更新用户头像
    [self.AvatarBtn setImage:imagesave forState:0];
    
    // 更换头像
    [self uploadIcon];
}


@end
